//
//  SectionViewController.m
//  Advertisement
//
//  Created by mac on 16/3/11.
//  Copyright © 2016年 Appcoda. All rights reserved.
//

#import "SectionViewController.h"
#import "VPNLabelAndTextFieldView.h"
@interface SectionViewController ()
//意见反馈
@property(nonatomic,strong)VPNLabelAndTextFieldView *nameView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *PhoneView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *emailView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *qqView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *weChatView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *adviceView;
//商务合作申请
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessNameView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businesscompanyView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessurlView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessPhoneView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessEmailView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessQQView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessweChatView;
@property(nonatomic,strong)VPNLabelAndTextFieldView *businessadviceView;

@end

@implementation SectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _userdefaults = [NSUserDefaults standardUserDefaults];

    NSString *indexPathRow = [NSString stringWithFormat:@"%@",[_userdefaults valueForKey:@"indexthRow"]];
    //NSLog(@"````````%@",indexPathRow);
//    int sectioNumber = indexPathSection.intValue;
    int rowNumber = indexPathRow.intValue;
    if (rowNumber == 2) {
        self.title = @"意见反馈";
        [self AddFeedback];
    }
    if(rowNumber == 3){
        self.title = @"商务合作申请";
        [self  AddApplication];
    }
    if (rowNumber == 7) {
        self.title = @"关于我们";
        [self AddAboutUs];

        }
}
//意见反馈部分
- (void)AddFeedback{
    _nameView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64, self.view.frame.size.width - 20, kScreenH*0.08)];
    _nameView.nameLabel.text = @"姓名";
    _nameView.valueField.placeholder = @"可选";
    _PhoneView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.08,  self.view.frame.size.width - 20, kScreenH*0.08)];
    _PhoneView.nameLabel.text = @"手机";
    _PhoneView.valueField.placeholder = @"可选";
    _emailView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.16,  self.view.frame.size.width - 20, kScreenH*0.08)];
    _emailView.nameLabel.text = @"邮箱";
    _emailView.valueField.placeholder = @"可选";
    _qqView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.24, self.view.frame.size.width - 20, kScreenH*0.08)];
    _qqView.nameLabel.text = @"QQ";
    _qqView.valueField.placeholder = @"可选";
    _weChatView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.32, self.view.frame.size.width - 20, kScreenH*0.08)];
    _weChatView.nameLabel.text = @"微信";
    _weChatView.valueField.placeholder = @"可选";
    
    
    _adviceView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,314,self.view.frame.size.width - 20, self.view.frame.size.height -314 -70)];
    //_adviceView.backgroundColor = [UIColor orangeColor];
    _adviceView.valueField.placeholder = @"请填写你的问题或者建议，我们将尽快处理";
    _submitButton = [[UIButton alloc]init];
    _submitButton.backgroundColor = BuleColor;
    [_submitButton setTitle:@"提交" forState:UIControlStateNormal];
    _submitButton.layer.borderColor = [UIColor whiteColor].CGColor;
    _submitButton.layer.borderWidth = 1;
    [_submitButton.layer setCornerRadius:8];
    [self.view addSubview:_submitButton];
    [_submitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(70, 30));
        make.left.mas_equalTo(kScreenW*0.5-35);
        make.right.mas_equalTo(-(kScreenW*0.5-35));
        make.bottom.mas_equalTo(-20);

    }];
    
    [self.view addSubview:_nameView];
    [self.view addSubview:_PhoneView];
    [self.view addSubview:_emailView];
    [self.view addSubview:_qqView];
    [self.view addSubview:_weChatView];
    [self.view addSubview:_adviceView];
    
     NSLog(@"进入了－－－－－－－－");
}
//商务合作申请部分
- (void)AddApplication{
    _businessNameView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64, self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessNameView.nameLabel.text = @"姓名";
    _businessNameView.valueField.placeholder = @"请填写商务合作联系人姓名";
    _businesscompanyView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.08,  self.view.frame.size.width - 20, kScreenH*0.08)];
    _businesscompanyView.nameLabel.text = @"公司";
    _businesscompanyView.valueField.placeholder = @"可选";
    _businessurlView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.16,  self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessurlView.nameLabel.text = @"网址";
    _businessurlView.valueField.placeholder = @"可选";
    _businessPhoneView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.24, self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessPhoneView.nameLabel.text = @"手机";
    _businessPhoneView.valueField.placeholder = @"请填写商务合作联系人手机";
    _businessEmailView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.32, self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessEmailView.nameLabel.text = @"邮箱";
    _businessEmailView.valueField.placeholder = @"请填写商务合作联系人邮箱";
    _businessQQView = [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.4, self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessQQView.nameLabel.text = @"QQ";
    _businessQQView.valueField.placeholder = @"可选";
    _businessweChatView= [[VPNLabelAndTextFieldView alloc]initWithFrame:CGRectMake( 10,64+kScreenH*0.48, self.view.frame.size.width - 20, kScreenH*0.08)];
    _businessweChatView.nameLabel.text = @"微信";
    _businessweChatView.valueField.placeholder = @"可选";
    
    
    [self.view addSubview:_businessNameView];
    [self.view addSubview:_businesscompanyView];
    [self.view addSubview:_businessurlView];
    [self.view addSubview:_businessPhoneView];
    [self.view addSubview:_businessEmailView];
    [self.view addSubview:_businessQQView];
    [self.view addSubview:_businessweChatView];
    
    
    
    _businesssubMitButton = [[UIButton alloc]init];
    _businesssubMitButton.backgroundColor = BuleColor;
    [_businesssubMitButton setTitle:@"提交" forState:UIControlStateNormal];
    _businesssubMitButton.layer.borderColor = [UIColor whiteColor].CGColor;
    _businesssubMitButton.layer.borderWidth = 1;
    [_businesssubMitButton.layer setCornerRadius:8];
    [self.view addSubview:_businesssubMitButton];
    [_businesssubMitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(70, 30));
        make.left.mas_equalTo(kScreenW*0.5-35);
        make.right.mas_equalTo(-(kScreenW*0.5-35));
        make.bottom.mas_equalTo(-20);
        
    }];


    _businessadviceView = [[VPNLabelAndTextFieldView alloc]init];
    //_adviceView.backgroundColor = [UIColor orangeColor];
    _businessadviceView.valueField.placeholder = @"请填写你的问题或者建议，我们将尽快处理";
    
    [self.view addSubview:_businessadviceView];
    [_businessadviceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_businessweChatView.mas_bottom).offset(0);
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.equalTo(_businesssubMitButton.mas_top).offset(-10);
    }];

    
    
}
//关于我们部分
- (void)AddAboutUs{
    _lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 174, kScreenW-10, 1)];
    _lineLabel.backgroundColor = GrayColor;
    [self.view addSubview:_lineLabel];
    _appImageView = [[UIImageView alloc]init];
    _appImageView.backgroundColor = BuleColor;
    //使图片四角成为圆弧形状
    _appImageView.layer.cornerRadius = 10;
    _appImageView.layer.masksToBounds = YES;
    [self.view addSubview:_appImageView];
    [_appImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 80));
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(74);

    
    }];
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.textColor = [UIColor grayColor];
   // nameLabel.backgroundColor = [UIColor redColor];
    nameLabel.text = @"ST";
    [self.view addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(120,30));
        make.left.equalTo(_appImageView.mas_right).offset(10);
        make.top.mas_equalTo(74);
    }];
    UILabel *synopsisLabel = [[UILabel alloc]init];
    synopsisLabel.text = @"Science and Technology";
    synopsisLabel.font = [UIFont systemFontOfSize:16];
     synopsisLabel.textColor = [UIColor grayColor];
   // synopsisLabel.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:synopsisLabel];
    [synopsisLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.top.equalTo(nameLabel.mas_bottom).offset(0);
        make.left.equalTo(_appImageView.mas_right).offset(10);
        make.right.mas_equalTo(-60);
    }];
    UILabel *versionsLabel = [[UILabel alloc]init];
    versionsLabel.text = @"版本号:V1.1.1";
    versionsLabel.textColor = [UIColor grayColor];
    versionsLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:versionsLabel];
    [versionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.top.equalTo(synopsisLabel.mas_bottom).offset(0);
        make.left.equalTo(_appImageView.mas_right).offset(10);
        make.right.mas_equalTo(-100);
    }];

    
    UIButton *awardDisplayBtn = [[UIButton alloc]init];
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"服务使用条款"];
    NSRange strRange = {0,[str length]};
    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
    [awardDisplayBtn setAttributedTitle:str forState:UIControlStateNormal];

    //[awardDisplayBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.view addSubview:awardDisplayBtn];
    [awardDisplayBtn addTarget:self action:@selector(hitbutton:) forControlEvents:UIControlEventTouchDown];
    [awardDisplayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(120,30));
                make.left.mas_equalTo(kScreenW*0.5 - 60);
                make.bottom.mas_equalTo(-50);
            }];
    UITextView *text = [[UITextView alloc]init];
    text.text = @"《ST》is an app for technology sharing.\r\n \r\n  You can get sufficient information from ST. \r\n \r\n   Any problem or suggestion please feedback to us.";
    text.font = [UIFont systemFontOfSize:18];
//    text.backgroundColor = [UIColor orangeColor];
    
    [self.view addSubview:text];
    [text mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(kScreenW,200));
        make.top.equalTo(_lineLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(0);
        
        
    }];
}
- (void)hitbutton:(UIButton *)sender{
    NSLog(@"odjfgoerjgoerjgor");
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    }

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
